package src.lab02.test01.Test17;

public class Test17 {
    public static void main(String[] args) {
        //实例化
        int[] numbers = new int[5];
        numbers[0] = 10;
        numbers[1] = 9;
        numbers[2] = 13;
        numbers[3] = 20;
        numbers[4] = 15;
        //打印所有元素
        //下标：0-4
        int index;
        for (index = 0; index < 5; index++) {
            System.out.println(numbers[index]);
        }
//输出该数组的最大值
        int max = 0;
        for (int i = 0; i < numbers.length; i++) {
            if (numbers[i] > max) {
                max = numbers[i];
            }
            System.out.println("max is:" + max);
        }
        //求和
        int sum = 0;
        for (int i = 0; i < numbers.length; i++) {
            //累加器
            sum += numbers[i];
            //sum=sum+numbers[i];

        }
    }
}
